﻿using System;
using System.Collections.Generic;

using System.Text;
using System.Web;

namespace DotNETX.Web.Authority
{
    public class Invalid2LoginUrlRedirecter : IRedirecter
    {
        public Invalid2LoginUrlRedirecter()
        {
            Redirect = XRedirect;
        }

        public void XRedirect(HttpContext context, string msg)
        {
            if (Config.LoginUrl != null)
            {
                context.Response.Redirect(Config.LoginUrl + context.Server.UrlPathEncode(context.Request.Path));//测试获取原始url(包含参数)
            }
            else
            {
                context.Response.Clear();
                context.Response.Write(DotNETX.Utility.Text.HtmlUtils.CreateHtml("身份验证失败", msg));
                context.Response.End();
            }
        }

        public RedirectHandler Redirect { get; set; }
    }
}
